import { WeaSearchGroup,WeaTools ,WeaErrorPage ,WeaFormItem } from 'ecCom';
import { WeaSwitch } from 'comsMobx';

class Condition extends React.Component{
    render(){
        let group = [];
        const {queryStore} = this.props;
        const { condition,form,col} = queryStore;
        /**常用查询条件 */
        const formParams = form.getFormParams();
        form.isFormInit && condition.map((v,ecindex) =>{
            let items = [];
            v.items.map(item => {
                const domKey = typeof item.domkey === "object" ? item.domkey[0] : item.domkey;
                items.push({
                    com:(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@rt6wng@${domKey}`}
                        label={`${item.label}`}
                        labelCol={{span: `${item.labelcol}`}}
                        wrapperCol={{span: `${item.fieldcol}`}}
                        error={form.getError(item)}
                        tipPosition="bottom"
                    >
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@g99xjp@${domKey}`} fieldConfig={item} form={form}/>
                    </WeaFormItem>),
                    colSpan:1
                });
            });

            group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@ke9w6z@${ecindex}`} needTigger={false} showGroup={true} items={items} col = {col || 2} />);

        });
        return <div>{group}</div>
    }
}

export default WeaTools.tryCatch(React,
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@brz04k`} msg={ props.error ? props.error : '对不起，该页面异常，请联系管理员！'} />,
    {error: ""}
)(Condition);